package com.dxyxx.dialog;

import com.dxyxx.R;

import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;

public class ViewTouchListener implements OnTouchListener {
	private Context context;
	private View button;

	public ViewTouchListener(Context context, View button) {
		this.context = context;
		this.button = button;
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		Animation animation = AnimationUtils.loadAnimation(this.context, R.anim.common_button_touch_animation);
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			button.startAnimation(animation);
			break;
		case MotionEvent.ACTION_UP:
			button.clearAnimation();
			break;
		default:
			break;
		}
		return false; // 还要将该事件传递给click处理
	}
}
